<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

jimport( 'joomla.application.component.view' );

/**
 * @package Joomla
 * @subpackage JobBoard
 */
class JobBoardViewJAUserGroup extends JView
{
	
    function display($tpl=null)
    {                
		$this->displayForm();
		parent::display($tpl);
    }
		   
	function displayUserGroup($selected='0')
	{
		$usergroup = &$this->get('_usergroup');		
        $r = JHTML::_('select.radiolist',   $usergroup, 'usergroup',  "class=\"inputbox\" ", 'value', 'text', $selected);      
		return $r;
	}
	
  	function displayForm()
  	{  	
		global $option;
		global $mainframe;
		
		
		
		$group = JRequest::getVar('group');
		$userdetail = JRequest::getVar('userdetail');
		$me 		= & JFactory::getUser();
		
		$temp_usertype = '';
		$temp_resume = getItemByFieldName('ja_resumes','user_id',$me->id);
		
		$temp_profile = getItemByFieldName('ja_profiles','user_id',$me->id);
		if (count($temp_resume))
		{
			$temp_usertype = 'Job Seeker User';
			JRequest::setVar('cid',$temp_resume[0]->id); 
			$group = 'Job Seeker User';
		}
		if (count($temp_profile))
		{
			$temp_usertype = 'Employer User';
			$group = 'Employer User';
		}
		
		   
		$cid		= JRequest::getVar( 'cid', array(0), '', 'array' );
		$edit		= JRequest::getVar('edit',true);
		JArrayHelper::toInteger($cid, array(0));
		
		$db 		=& JFactory::getDBO();
//		if ($userdetail)
		$user		=& JUser::getInstance($me->id);
//		elseif($edit)
//			$user 		=& JUser::getInstance( $cid[0] );
//		else
//			$user 		=& JUser::getInstance();
		$acl		=& JFactory::getACL();
	
		// Check for post data in the event that we are returning
		// from a unsuccessful attempt to save data
		$post = JRequest::get('post');
		if ( $post ) {
			$user->bind($post);
		}
		// build the html select list
		$lists['block'] 	= JHTML::_('select.booleanlist',  'block', 'class="inputbox" size="1"', $user->get('block') );
	
		// build the html select list
		$lists['sendEmail'] = JHTML::_('select.booleanlist',  'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') );
	//print_r($user);exit;
		$this->assignRef('temp_usertype',	$temp_usertype);
		$this->assignRef('me',	$me);
		$this->assignRef('lists',	$lists);
		$this->assignRef('user',	$user);
		$this->assignRef('contact',	$contact);
		$this->assignRef('option',	$option);
		
		require_once JPATH_COMPONENT_SITE.DS.'models'.DS.'jaresumes.php';
		$model_resume = new JobBoardModelJAresumes();
		require_once JPATH_COMPONENT_SITE.DS.'models'.DS.'japrofiles.php';
		$model_profile = new JobBoardModelJAProfiles();
		$item_resume = $model_resume->getItem($me->id);  	
		$item_profile = $model_profile->getItem($me->id);
//		var_dump($item_resume);
		if(JRequest::getVar('postback', false)){
			if ($group=='Job Seeker User')
            	$item_resume->bind($post);
            else 
            {
            	$item_profile->bind($post);
            }
        }
		$fieldList = getEditFieldList('ja_resumes');
		$this->assignRef('fieldlist', $fieldList);
  	    $this->assignRef('item_resume', $item_resume);
  	    $this->assignRef('item_profile', $item_profile);
  	    
  	    require_once JPATH_COMPONENT_SITE.DS.'models'.DS.'jaemployers.php';
		$model = new JobBoardModelJAEmployers();
  	    $em_item = $model->getItem();  	
		$em_fieldList = getEditFieldList('ja_profiles');
		$this->assignRef('em_fieldlist', $em_fieldList);
  	    $this->assignRef('em_item', $em_item);
  	    $this->assignRef('Itemid', JRequest::getInt('Itemid'));
				
	}
	
    function menu($usertype)
	{
		$task = JRequest::getVar('task', 'user');
		$cid    = JRequest::getVar( 'cid', array(), 'get', 'array' );
        JArrayHelper::toInteger($cid);
        $cid = $cid[0];
		?>
			
			<div class="m">
				<ul id="submenu">
				<?php
						if ($usertype==JBJOB_SEEKER_USER) 
						{
					?>
					<li>
						<a href="index.php?option=com_jajobboard&view=jausergroup&userdetail=true&group=<?php echo $usertype; ?>&task=user&cid[]=<?php echo $cid;?>"class="<?php if($task==null||$task=='user')echo 'active' ?>">
							<?php echo JText::_( 'User Details' ); ?>
						</a>
					</li>				
					<li>
								
							<a href="index.php?option=com_jajobboard&view=jaresumes&userdetail=true&group=<?php echo $usertype; ?>&task=edit&cid[]=<?php echo $cid;?>" class="<?php if($task=='resume')echo 'active' ?>" >
								<?php echo JText::_( 'Resume Details' ); ?>
							</a>
					</li>
					<?php 
						}
						elseif ($usertype==JBEMPLOYER_USER)
						{
					?>
					<li>
						<a href="index.php?option=com_jajobboard&view=jausergroup&userdetail=true&group=<?php echo $usertype; ?>&task=user&cid[]=<?php echo $cid;?>"class="<?php if ($task==null||$task=='user')echo 'active' ?>">
							<?php echo JText::_( 'Employer Details' ); ?>
						</a>
					</li>				
					<li>
						<a href="index.php?option=com_jajobboard&view=japrofiles&userdetail=true&group=<?php echo $usertype; ?>&task=edit&cid[]=<?php echo $cid;?>" class="<?php if($task=='resume')echo 'active' ?>" >
							<?php echo JText::_( 'Profile Details' ); ?>
						</a>
					</li>					
					<?php
						}
					?>
						
					<li>
<!--						<a href="index.php?option=com_jl_project&view=jl_profile&task=listpermission&type=permission&usergroup=guest_permission"class="<?php if($usergroup=='guest_permission')echo 'active' ?>">
							<?php //echo JText::_( 'Payment Details' ); ?>
						</a>  -->
					</li>					
				</ul>
				<div class="clr"></div>
			</div>
				
		<?php		
	}	
	
}
?>